using System.Globalization;
using iPhOwa.Exchange.Attributes;
using iPhOwa.Exchange.ContentClasses.Fields;

namespace iPhOwa.Exchange.ContentClasses
{
	/// <summary>
	/// A person (contact) item
	/// </summary>
	[ExchangeContentClass(ContentClassNames.Person)]
	public class Contact : Item
	{
		private string company;
		private string firstName;
		private string lastName;
		private string mobilePhone;
		private string workPhone;

		/// <summary>
		/// Given first name.
		/// </summary>
		[ExchangeField(ContactFields.FirstName)]
		public string FirstName
		{
			get { return firstName; }
			set { firstName = value; }
		}

		/// <summary>
		/// Last name or surname.
		/// </summary>
		[ExchangeField(ContactFields.LastName)]
		public string LastName
		{
			get { return lastName; }
			set { lastName = value; }
		}

		/// <summary>
		/// Company or orgnaization.
		/// </summary>
		[ExchangeField(ContactFields.Organization)]
		public string Company
		{
			get { return company; }
			set { company = value; }
		}

		/// <summary>
		/// Mobile phone number
		/// </summary>
		[ExchangeField(ContactFields.Mobile)]
		public string MobilePhone
		{
			get { return mobilePhone; }
			set { mobilePhone = value; }
		}

		/// <summary>
		/// Work phone number.
		/// </summary>
		[ExchangeField(ContactFields.TelephoneNumber)]
		public string WorkPhone
		{
			get { return workPhone; }
			set { workPhone = value; }
		}

		/// <summary>
		/// The display name.
		/// </summary>
		public new string DisplayName
		{
			get { return string.Format(CultureInfo.CurrentCulture, "{0} {1}", FirstName, LastName); }
		}

		/// <summary>
		/// Indicates whether this contact is a company or a person.
		/// </summary>
		public bool IsCompany
		{
			get { return string.IsNullOrEmpty(FirstName) && string.IsNullOrEmpty(LastName); }
		}
	}
}